import tradeApi from "@/api/declaration/mall/tradeApi"
import httpRequest from "@/config/axios/httpRequest"
import { TradeTrendReqModel } from "@/models/mall/TradeSummaryRespModel"
import { formatDate } from "@/utils/formatTime"
import dayjs from "dayjs"


// 查询交易统计
export const getTradeStatisticsSummary = () => {
  return httpRequest.get(tradeApi.GetTradeStatisticsSummary)
}

// 获得交易状况统计
export const getTradeStatisticsAnalyse = (params: TradeTrendReqModel) => {
  return httpRequest.get(tradeApi.GetTradeStatisticsAnalyse, {params})
}

// 获得交易状况明细
export const getTradeStatisticsList = (params: TradeTrendReqModel) => {
  return httpRequest.get(tradeApi.GetTradeStatisticsList, {params})
}

// 导出交易状况明细
export const exportTradeStatisticsExcel = (params: TradeTrendReqModel) => {
  return httpRequest.download(tradeApi.ExportTradeStatisticsExcel, {params})
}

// 获得交易订单数量
export const getOrderCount = async () => {
  return await httpRequest.get(tradeApi.GetOrderCount)
}

// 获得交易订单数量对照
export const getOrderComparison = async () => {
  return await httpRequest.get(tradeApi.GetOrderComparison)
}

// 获得订单量趋势统计
export const getOrderCountTrendComparison = (
  type: number,
  beginTime: dayjs.ConfigType,
  endTime: dayjs.ConfigType
) => {
  return httpRequest.get(tradeApi.GetOrderCountTrendComparison, {
    params: {
      type,
      beginTime: formatDate(dayjs(beginTime).toDate()),
      endTime: formatDate(dayjs(endTime).toDate())
    }
  })
}


